import { Modal, Button } from 'antd';
import React from 'react';
import purchasing from '../../../service/Purchasing'
class DelOrder extends React.Component {
  state = {
    visible: false,
    text: '',
    data: '',
  };

  showModal = () => {
    this.setState({
      visible: true,
    });
  };

  handleOk = e => {
    // console.log(e);
    this.setState({
      visible: false,
    });
    console.log('删除')

    //删除请求
    purchasing.Delete_PurOrder({
      method: "POST",
      data: {
        purchase_order_id: this.props.id
      }
    })
      .then((res) => {
        console.log('res1', res)
      })
      .catch((err) => {
        console.log('err', err)
      })
  };

  handleCancel = e => {
    console.log(e);
    this.setState({
      visible: false,
    });
  };

  render() {
    return (
      <div>
        <a href='#!' onClick={this.showModal}>
          {this.props.text}
        </a>
        <Modal
          title="删除订单"
          visible={this.state.visible}
          onOk={this.handleOk}
          onCancel={this.handleCancel}
          footer={[
            <Button key="submit" type="primary" onClick={this.handleOk}  >确定删除</Button>,
            <Button key="back" onClick={this.handleCancel}>取消删除</Button>,
          ]}

        >
          <p>请确认是否删除订单</p>
          <p>订单编号为:{this.props.id}</p>
        </Modal>
      </div>
    );
  }
}

export default DelOrder;